﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ecdl.demo.model;

namespace ecdl.demo.ui.task {

    /// <summary>
    /// Interaction logic for TaskEvaluationWindow.xaml
    /// </summary>
    public partial class TaskEvaluationWindow : Window, ITaskEvaluationPresenter {

        private BitmapImage correctImageSource;
        private BitmapImage falseImageSource;

        public TaskEvaluationWindow() {

            correctImageSource = new BitmapImage(new Uri("/ecdl.demo.ui;component/ui/task/img/correct.png", UriKind.Relative));
            falseImageSource = new BitmapImage(new Uri("/ecdl.demo.ui;component/ui/task/img/false.png", UriKind.Relative));
            InitializeComponent();
        }

        public void ShowTaskEvaluation(bool isCorrect, string cause) {
            if (isCorrect) {
                this.TaskEvaluationLabel.Content = "Sie haben die Frage richtig beantwortet";
                this.HintLabel.Visibility = System.Windows.Visibility.Hidden;
                this.ErrorDescriptionLabel.Visibility = System.Windows.Visibility.Hidden;

                this.EvaluationImage.Source = correctImageSource;

                this.TaskEvaluationLabel.Foreground = Brushes.Green;

            } else {
                this.TaskEvaluationLabel.Content = "Sie haben die Frage falsch beantwortet";
                this.HintLabel.Visibility = System.Windows.Visibility.Visible;
                this.ErrorDescriptionLabel.Visibility = System.Windows.Visibility.Visible;
                this.ErrorDescriptionLabel.Content = cause;

                this.EvaluationImage.Source = falseImageSource;

                this.TaskEvaluationLabel.Foreground = Brushes.Red;
            }
            this.Owner = Application.Current.Windows[1];
            this.ShowDialog();
        }

        private void OnNextButtonClicked(object sender, RoutedEventArgs e) {
            this.Close();
        }
    }

}
